home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6147 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Keyboard buffer problems...please help!
  5. Date: 22 Feb 1996 11:48:22 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4giha6INN9pg@keats.ugrad.cs.ubc.ca>
  8. References: <3126B507.4052@canna.ucsd.edu>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <3126B507.4052@canna.ucsd.edu>,
  12. Eric C. Liebl <ecl@canna.ucsd.edu> wrote:
  13.  >I am looking for a C command that will flush the keyboard buffer before 
  14.  >it is read.  I am using Borland C/C++ 4.0 to compile my program.  
  15.  
  16. This question crops up about three times a week. It is definitely addressed in
  17. the FAQ.
  18.  
  19. The C language has no concepts of keyboards, screens or any such thing. There
  20. is no way to clear the keyboard buffer, since this is maintained either by
  21. hardware, or by some sort of operating system terminal or console driver.
  22.  
  23.  >when an appropriate key is hit I update graphics, etc. in my 
  24.  >program.  However, if a user holds the key down the key data fills the 
  25.  >keyboard buffer and I get an annoying beep and too many "moves" get 
  26.  >stored up in advance.
  27.  
  28. If you are doing graphics, you might as well deviate from standard C library
  29. functions in your handling of user input. Your graphics API surely includes
  30. ways to get unbuffered keyboard and mouse input? 
  31.  
  32. For example, if you were using the X11 library to communicate with an X
  33. display, you would receive detailed events regarding keys being pressed and
  34. released in a particular window.
  35.  
  36. Read the FAQ and the information that comes with your programming environment.
  37. -- 
  38.  
  39.